<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<!-- $Id: input-data.php 392 2009-03-10 23:35:33Z cameron.bracken $ -->

<!-- PondSim website version 2 rewritten by Cameron Bracken -->
<!-- Website originally written by Jordan Pierce -->
<!-- PondSim written by Neil Berezovsky -->

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>PondSim Data input</title>
    <meta name="author" content="cameron">
    <link rel="stylesheet" type="text/css" href="static/style.css">
    <link rel="shortcut icon" href="img/favicon.ico">
	<script type="text/javascript" src="static/functions.js"></script>
</head>
<body>
	
	<?php include("sandbox/www/vars.php"); ?>
	
	<div id='content'>
		<?php include('static/header.html'); ?>
		
		<h1>PondSim Data Input</h1>
		<!---->
		<!---->
		<!--Previous run selection-->
		<!---->
		<!---->
		
		<h2>Load Previous Run</h2>
		<hr>
		
		<form method='get' action='load-run.php'>
			<?php include('chunks/pulldown.php'); ?>
			<input name='type' style='visibility:hidden;width:0' value='param'>
			<input type='submit' value='Load Data'>
		</form>

		<form method='get' action="run.php">
			<p>Please note: Data is not saved until the "Run Model" button is pressed</p>
			<div id="inputs">

				<!---->
				<!---->
				<!--Run Description Section-->
				<!---->
				<!---->
			
				<h2>Run Description</h2>
				<hr>
				
				<p>Please enter a short run description</p>
				<input name='rundes' style='width:300px' value='My PondSim Run'/>
						
				<!---->
				<!---->
				<!--Simulation length selection-->
				<!---->
				<!---->
				
				<h2>Inflow and Precipitation</h2>
				<hr>
				
				<table>
					<tr><td colspan="4">
							Simulation Length (days):
							<?php
								//Writes the simulation length button;
								for($i=1; $i<=$maxdays; $i++){
									echo "<input name='simlen' type='radio' class='radio' value='$i' onclick='redeye($i)'";
									if($i==$simlen){echo"checked";}
									echo ">$i</input>\n";
								}
							?>
						</td>
					</tr>
					<tr>
						<th colspan="2">Plant Inflow (MGD)    </th>
						<th colspan="2">Precipitation (inches)</th>
					</tr>
						<?php
							//writes the input boxes for each day, by default on the first row is showing 
							//the $inflow and $rainfall variables are from vars.php
							for ($i=1; $i<=3; $i++){
								echo "<tr id='day$i'";
								if($i > 1) echo "style='visibility: collapse'";
								echo ">\n<td>Day $i:</td><td><input class='textbox' name='plant_inflow_rate_day$i' value='$inflow[$i]' /></td>\n";
								echo "<td>Day $i:</td><td><input class='textbox' name='rainfall_day$i' value='$rainfall[$i]' /></td>\n</tr>\n";
							}
						?>					
				</table>
				<script type='text/javascript'>redeye(<?=$simlen?>);</script>
	
				<!---->
				<!---->
				<!-- Water surface input area -->	
				<!---->
				<!---->
						
				<h2 onclick="document.getElementById('wselev').style.visibility='visible'">Water Surface Elevations</h2>  
				<hr>
				
				<div id='wselev'>
					<p>Input elevations as <b style='color:black'>Depth from Water Surface in inches</b></p>
						<?php 
							//write the water surface elevation input forms
							//The values in $desc and $ponds comes from vars.php
							//insert row endings so that all the ox and tm are are on the same line
							$i = 0;
							echo"<table>\n<tr>";
							foreach($pond_height as $pond => $ht){
								echo "<td>$pond</td>\n";
								echo "<td><input name='pond_height_$pond' class='textbox' onfocus='document.getElementById(\"Description\").value=\"$desc[$pond]\";'";
								echo "value='$ht'></input> </td>\n";
								if($pond == "Ox3" | $pond == "TM4"){
									echo"</tr>\n<tr>";
								};
								$i++;
							};
							echo"</tr>\n</table>";
						?>
					<textarea id="Description" rows="3" cols="50" readonly>Click on an input box to see its description</textarea></br>
				</div>
	
				<!---->
				<!---->
				<!-- Automatic Settings input area -->	
				<!---->
				<!---->
						
				<h2 onclick="document.getElementById('auto').style.visibility='visible'">Automatic Settings</h2>
				<hr>
				
				<div id='auto'>
					<p> If level is selected then enter target pond height in feet, if flow is selected then enter a target outflow in MGD.</p><br/>
					<table>
					<tr><th>Pond</th><th>Specified</th><th>Height (ft)</th><th>Flow (MGD)</th></tr>
						<?php
							//Writes the automatic settings input areas
							foreach($auto as $pond => $val){
								echo "<tr>\n<td>$pond</td><td>\n";
								//Specified Height Button switch off the flow box
								echo "<input type='radio' class='radio' name='auto_$pond' value='1'";
								if ($val == 1){echo " checked ";}
								echo " onclick=\"autoSwitch('target_height_$pond','target_flow_$pond',1)\">Height</input>\n";
								
								//Specified Flow button switches off the height box
								echo "<input type='radio' class='radio' name='auto_$pond' value='2'";
								if ($val == 2){echo " checked ";}
								echo " onclick=\"autoSwitch('target_height_$pond','target_flow_$pond',2)\">Flow</input>\n";
								
								//Neither Button Switches off both
								echo "<input type='radio' class='radio' name='auto_$pond' value='0'";
								if ($val == 0){echo " checked ";}
								echo "onclick=\"autoSwitch('target_flow_$pond','target_height_$pond',0)\">Neither</input></td>\n";
								
								//Boxes
								echo "<td><input class='textbox' name='target_height_$pond' value='$target_ht[$pond]'></input></td>\n";
								echo "<td><input class='textbox' name='target_flow_$pond' value='$target_flow[$pond]'></input></td>\n";
								echo "</tr>";
								echo "<script type='text/javascript'>autoSwitch('target_height_$pond','target_flow_$pond',$val);</script>";
							}
						?>
					</table>
					Target Wetland Influent: <input class='textbox' name='target_wetland_influent' value="<?=$target_wetland_influent?>"/> MGD
					(Leave blank for "No Target Wetland Influent")
				</div>
	
				<!---->
				<!---->
				<!-- Weir Settings input area -->	
				<!---->
				<!---->
						
				<h2 onclick="document.getElementById('weirs').style.visibility='visible'">Weir Settings</h2>
				<hr>
				
				<div id='weirs'>
					<p> Weir heights are measured in <strong style='color:black'>inches from the water surface</strong></p> <br />
		
					<table>
						<tr><th>Description</th><th>From Top</th>
						<?php
							//writes the weir descriptions
							//values in routes comes from vars.php
							foreach($weirs as $weir => $ht){
								echo"<tr><td>$con[$weir]</td><td><input class='textbox' name='weir_height_$weir' value='$ht'></input> </td></tr>\n";
							}
						?>				
					</table>
				</div>
	
				<!---->
				<!---->
				<!-- Pump Settings input area -->	
				<!---->
				<!---->
	
				<h2 onclick="document.getElementById('pumps').style.visibility='visible'">Pump Settings</h2>
				<hr>
				
				<div id='pumps'>
					<p> Pumping capacities are measured in MGD </p>
		
		
					<table>
						<tr><th>Description</th><th> Use pump </th><th>Hours On</th><th>Offset Hours</th></tr>
						<?php 
							//writes pumping hours input form
							foreach ($pumps as $pump => $rate){
								echo "<tr><td>$con[$pump]: </td><td>\n";
								echo "<input type='radio' class='radio' name='pump_on_$pump' value='1' ";
								if($pump_on[$pump]==1){echo"checked";}else{echo"";}
								echo ">on</value>\n";
								echo "<input type='radio' class='radio' name='pump_on_$pump' value='0' ";
								if($pump_on[$pump]==0){echo"checked";}else{echo"";}
								echo ">off</value>\n";
								echo "</td><td>\n";
								echo "<input class='textbox' name='hours_$pump' value='$hours[$pump]' >\n";
								echo "</td><td><input class='textbox' name='offset_$pump' value='$offset[$pump]'></td></tr>\n";
							}
						?>
					</table>
				</div>
			</div>
	
			<input type="submit" value="Run Model"/>
		</form>

		<div id='footer'>
			<!-- menu -->
			<?php include('static/footer.html');?>
			<p>$Id: input-data.php 392 2009-03-10 23:35:33Z cameron.bracken $</p>
		</div>
	</div>
</body>
</html>
